home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / falcon / programm.ing / falclib2.lzh / ROUTS / WINEVENT.S < prev   
Text File  |  1994-08-17  |  2KB  |  78 lines

  1. *
  2. * WINEVENT.S
  3. *
  4. *    @dowindowevents
  5. *     For the lazy one. This function waits for events and takes care of
  6. *     everything but the close button or if someone clicked on an object.
  7. *     If one of these events occur the program branches to closeevent
  8. *     or buttonevent. Those subroutines you have to make yourself.
  9. * In     a0.l=adr. to rsrc
  10. *     w_handle, ap_id  (These are created automatically if you use @createwindow)
  11. * Out     buttonevent: d0.w=number of the object pressed
  12. *     closeevent: nothing
  13. *     (destroys a lot)
  14. *
  15. * ex.    ;create a window;
  16. *    lea rsrc,a0
  17. *    bra @dowindowevents    ; it will never return so you may use 'bra'
  18. * buttonevent        ; d0.w will contain the object that was pressed
  19. *    cmp #1,d0     ; was it my button?
  20. *     beq mybutton    ; yes!
  21. *    rts        ; no!
  22. * closeevent
  23. *    bsr @exitwindow    ; close window
  24. *    bra @quit    ; quit
  25. *
  26.  
  27.         include    window.s
  28.  
  29.  
  30. @dowindowevents    move.l    a0,.rsrcadr
  31. .again        evnt_multi #%010010,#1,#1,#1,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#.msgbuf,#0    ;get message and button events
  32.         btst.b    #4,int_out+1
  33.         bne    .msgevent
  34. .msgready    btst.b    #1,int_out+1
  35.         bne    .buttonevent
  36.         bra    .again
  37.  
  38. .msgevent    move    .msgbuf,d0
  39.         cmp    #20,d0        is it an update event?
  40.         beq    .redraw
  41.         cmp    #22,d0        was the close box pressed?
  42.         beq    .exit
  43.         cmp    #28,d0        was the window moved?
  44.         beq    .moved
  45.         cmp    #23,d0        was the full button pressed
  46.         beq    .full
  47.         cmp    #21,d0        was the window topped?
  48.         beq    .topped
  49.         cmp    #33,d0        was it bottomed?
  50.         beq    .bottomed
  51.         bra    .msgready    it was something unimportant
  52.         
  53. .buttonevent    move.l    .rsrcadr,a0
  54.         bsr    @button
  55.         tst    d0        did someone press anything?
  56.         bmi    .again        no!
  57.         bsr    buttonevent
  58.         bra    .again
  59.         
  60. .exit        bsr    closeevent
  61.         bra    .msgready
  62. .redraw        move.l    .rsrcadr,a0
  63.         bsr    @updatersrc
  64.         bra    .msgready
  65. .moved        lea    .msgbuf,a0
  66.         bsr    @moveit
  67.         bra    .msgready
  68. .bottomed    lea    .msgbuf,a0
  69.         bsr    @bottomwindow
  70.         bra    .msgready
  71. .topped        lea    .msgbuf,a0
  72.         bsr    @topwindow
  73.         bra    .msgready
  74. .full        bra    .msgready
  75.  
  76. .msgbuf        ds.w    20
  77. .rsrcadr    ds.l    1
  78.